package com.hutao.manage.service.impl;

import java.util.List;

import org.apache.shiro.util.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hutao.manage.mapper.TCzyMapper;
import com.hutao.manage.pojo.LoginPojo;
import com.hutao.manage.service.UserService;
import com.hutao.manage.util.Result;

@Service
public class UserServiceImpl implements UserService{

	@Autowired
	private TCzyMapper tczyMapper;
	

	@Override
	public Result login(String name,String password,String orgCode) {
		Result result = null;
		LoginPojo loginPojo = tczyMapper.getLoginByNameAndPassword(name, password, orgCode);
		if(loginPojo==null) {
			result = new Result(false,"用户名或密码错误!");
		    return result;
		}
		result = new Result(true,"查询成功!",loginPojo);
		return result;
	}

	@Override
	public LoginPojo loginByName(String name, String orgCode) {
		List<LoginPojo> loginPojoList = tczyMapper.getLoginByUserName(name, orgCode);
		if(CollectionUtils.isEmpty(loginPojoList)) {
			return null;
		}
		return loginPojoList.get(0);
	}

	


	
	
}
